﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ecreate.Data
{
    public class FactoryDBEngine
    {
        private static DBEngine instance = null;
        public static DBEngine GetInstance()
        {
            if (instance == null)
            {
                WebConfigAccess configAccess = new WebConfigAccess();
                if (configAccess.DataBaseType == DataBaseType.MSSQLServer)
                {
                    instance = new SqlServerDBEngine(configAccess.ConnectionString);
                }
                else if (configAccess.DataBaseType == DataBaseType.Oracle)
                {
                    instance = new OracleDBEngine(configAccess.ConnectionString);
                }
                else if (configAccess.DataBaseType == DataBaseType.Sqlite)
                {
                    instance = new SqliteDBEngine(configAccess.ConnectionString);
                }
            }
            return instance;
        }
        public static IFace.IIBatisService getIBatisService()
        {
            return Ecreate.Data.FactoryDBEngine.GetInstance().getService().getIBatisService();
        }
        public static IFace.IHibernateService getHibernateService()
        {
            return Ecreate.Data.FactoryDBEngine.GetInstance().getService().getHibernateService();
        }
        public static IBatisNet.DataMapper.ISqlMapper SqlMapper()
        {
            return Ecreate.Data.FactoryDBEngine.getIBatisService().getIMapper();
        }
    }





}
